<template>
    <el-dialog v-model="dialogStore.isShareTemplateDialogVisible" class="share-template-dialog" append-to-body
        :close-on-click-modal="false" :close-on-press-escape="false" :lock-scroll="false" top="20vh" width="610px"
        height="290px" title="分享">
        <div class="share-template-dialog__main">
            <div class="share-template-dialog__left">
                <div class="qrcode">
                    <img :src="QrCodeUrl" />
                </div>
                <el-button type="primary" plain @click="onDownloadQrCode">
                    下载二维码
                </el-button>
            </div>
            <div class="share-template-dialog__right">
                <div class="share-title">
                    {{ dialogStore.shareTitle || "作品链接" }}
                </div>
                <div class="share-url-box">{{ dialogStore.shareUrl }}</div>
                <div class="copy-btn" @click="onCopyUrl">复制</div>
            </div>
        </div>
    </el-dialog>
</template>
<script setup>
import { useContent } from ".";
const { dialogStore, QrCodeUrl, onCopyUrl, onDownloadQrCode } = useContent();
</script>
<style lang="scss">
.share-template-dialog {
    border-radius: 10px !important;
    user-select: none;

    .el-dialog__header {
        text-align: center;

        .el-dialog__title {
            font-weight: 500;
        }
    }

    &__main {
        display: flex;
        padding: 0 20px;
    }

    &__left {
        text-align: center;

        .qrcode {
            width: 140px;
            height: 140px;
            margin-bottom: 10px;

            img {
                width: 100%;
                height: 100%;
            }
        }
    }

    &__right {
        display: flex;
        flex-direction: column;
        padding-top: 20px;
        margin-left: 27px;

        .share-title {
            font-size: 14px;
            color: #333;
        }

        .share-url-box {
            width: 350px;
            line-height: 40px;
            padding: 0 9px;
            margin-top: 20px;
            border: 1px solid #ddd;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            box-sizing: border-box;
        }

        .copy-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 60px;
            height: 28px;
            margin-top: 20px;
            margin-left: auto;
            color: #fff;
            background-color: #5085fb;
            border-radius: 4px;
            cursor: pointer;
        }
    }
}
</style>
